﻿@*@model IEnumerable<UscSunShine.ViewModels.PostViewModel>*@

@model PagedList.IPagedList<UscSunShine.Models.Post>
@using PagedList.Mvc;

<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/bootstrap-select.css")" rel="stylesheet" type="text/css" />
@{
    ViewBag.Title = "公告列表";
}
<!-- <h2>Index</h2>-->


<div class="jumbotron font-detail">
    <div class="container">
        @*<p>
                @Html.ActionLink("新建", "Create")
            </p>*@
        <fieldset>
            <legend>公告列表</legend>
            @using (Html.BeginForm("Index", "Post", FormMethod.Get, new { @class = "bs-example bs-example-form" }))
            {
                <table>
                    <tr>
                        <td >
                            办事机构：
                            @Html.DropDownList("departmentID", ViewBag.departmentID as SelectList, "全部", new { @class = "selectpicker" })
                        </td>
                        <td >
                            类别：
                            @Html.DropDownList("postCategory", ViewBag.postCategory as SelectList,"全部", new { @class = "selectpicker" })
                        </td>
                        <td >
                            <div class="input-group">
                                <span class="input-group-addon">标题：</span>
                                @*<input type="text" class="form-control" placeholder="twitterhandle">*@
                                @Html.TextBox("titleSearchString", ViewBag.currentTitle as string, new { @class = "form-control" })
                            </div>
                        </td>
                        <td align="right">
                            <button type="submit" class="btn btn-default">查  询</button>
                        </td>
                    </tr>
                </table> 
            }
            <center>
                <table id="infoListTable" class="table table-hover">
                    <tr>
                        <th>
                            @Html.DisplayNameFor(model => model.FirstOrDefault().Department.Name)
                        </th>
                        <th style="width:15%;">
                            @Html.DisplayNameFor(model => model.FirstOrDefault().PostCategory)
                        </th>
                        <th style="width:45%;">
                            @Html.DisplayNameFor(model => model.FirstOrDefault().Title)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.FirstOrDefault().InputDate)
                        </th>
                        <th>
                            @Html.DisplayNameFor(model => model.FirstOrDefault().ViewTimes)
                        </th>
                        @*<th>
                                操作
                            </th>*@
                    </tr>

                    @foreach (var item in Model)
                    {
                        <tr>
                            <td class="longItem">
                                @Html.DisplayFor(modelItem => item.Department.Name)
                            </td>
                            <td style="width:15%;">
                                @Html.DisplayFor(modelItem => item.PostCategory)
                            </td>
                            <td class="longItem" style="width:45%;">
                                @*@Html.DisplayFor(modelItem => item.Title)*@
                                @Html.ActionLink(item.Title, "Details", new { id = item.ID })
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.InputDate)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.ViewTimes)
                            </td>

                            @*<td style="vertical-align:middle;">
                                    @Html.ActionLink("编辑", "Edit", new { id = item.ID }) |
                                    @Html.ActionLink("删除", "Delete", new { id = item.ID }, new { @onclick="return confirm('确认删除?')"})
                                </td>*@
                        </tr>
                    }

                </table>

                <br />
                第 @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) 页，共 @Model.PageCount 页
                @Html.PagedListPager(Model, page => Url.Action("Index", new
                {
                    page,
                    currentTitle = ViewBag.currentTitle,
                    currentDepartmentID = ViewBag.currentDepartmentID,
                    currentCategory = ViewBag.currentCategory
                }))
            </center>
        </fieldset>

    </div>
</div>
<script src="@Url.Content("~/Scripts/jquery-2.1.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-select.min.js")" type="text/javascript"></script>